package com.itheima.movieExample;

import java.util.Scanner;

public class MovieOperator {
    private Movie[] movies;

    public MovieOperator(){

    }
    public MovieOperator(Movie[] movies ){
        this.movies  = movies;
    }

    public void printMovies(){
        for (int i = 0; i < movies.length; i++) {
            Movie m = movies[i];
            System.out.println(m.getId() +"\t"+ m.getName() +"\t"+m.getPrice() +"\t"+ m.getActor());
        }
    }

    public void findMovie(){
        System.out.println("请输入id 查询电影");
        Scanner sc = new Scanner(System.in);
        int id = sc.nextInt();

        for (int i = 0; i < movies.length; i++) {
            Movie m = movies[i];
            if(m.getId() == id){
                System.out.println("当前查出的电影是"+ m.getName());
                return;
            }
        }
        System.out.println("没有找到");
    }
}
